package com.icss.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.icss.model.Cart;
import com.icss.model.Item;
import com.icss.service.CartService;

@Controller
@RequestMapping("CartController")
public class CartController {
	@Autowired
	CartService cs;
	
	//去购物车
	@RequestMapping("cart")
	public String cart(@RequestParam("id")int id,Map<String, Object>map){
		List<Item> findByuserId = cs.findByuserId(id);
		map.put("cart", findByuserId);
		return "cart/cart";
	}
	@ResponseBody
	@RequestMapping(value="add",produces= {"text/html; charset=UTF-8"})
	public String add(Cart cart) {
		boolean addcart = cs.addcart(cart);
		if(addcart) {
			return "成功";
		}else {
			return "失败";
		}
	}
}
